package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.ThingBean;
import com.project.dao.IThingDao;
import com.project.service.IThingService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

/**
 * @author RJ
 * @date 2022/9/15 9:05
 */
@Service
@Transactional
public class ThingServiceImpl extends ServiceImpl<IThingDao, ThingBean> implements IThingService {

    @Override
    public void addThing(ThingBean thingBean) {
        this.save(thingBean);
    }

    @Override
    public ThingBean getThingInfo(Integer thingId) {
        return this.baseMapper.getThingInfo(thingId);
    }

    @Override
    public void updThing(Integer thingId, String thingStage, String thingScheme) {
        this.baseMapper.updThing(thingId, thingStage, thingScheme);
    }

    @Override
    public IPage<ThingBean> cutThingByItem(Integer pageNo, Integer pageSize, String thingName, String thingStage,
                                           String areaName, LocalDate startDate, LocalDate endDate) {
        Page<ThingBean> page = new Page<>(pageNo, pageSize);
        IPage<ThingBean> iPage = this.baseMapper.cutThingByItem(page, thingName, thingStage, areaName, startDate, endDate);
        return iPage;
    }

    @Override
    public void updStage(Integer thingId, String thingStage) {
        this.baseMapper.updStage(thingId, thingStage);
    }
}
